package example.demo1.controller;

import example.demo1.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RequestController {
    @RequestMapping("/param1")
    public String param1(String userName) {
        System.out.println("接收到的参数： "+userName);
        return "接收到的参数："+userName;
    }
    @RequestMapping("/param2")
    public String param2(Integer age) {
        return "2接收的参数："+age;
    }
    @RequestMapping("/param3")
    public String param2(int age) {
        return "3接收的参数："+age;
    }
    @RequestMapping("/param4")
    public String param4(String username,String password) {
        return "接收到的参数userinfo："+username +",password: "+password;
    }
    @RequestMapping("/param5")
    public String param5(UserInfo userInfo) {
        System.out.println(userInfo.getUserName());
        return "5返回的参数"+userInfo;
    }
    @RequestMapping("param6")
    public String param6(@RequestParam(value = "userName",required = false)String name,String password) {
        return "接收的参数name："+name+",password: "+password;
    }
}
